load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "extsort",
    srcs = [
        "disk_sorter.go",
        "external_sorter.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/util/extsort",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/util/generic",
        "//pkg/util/syncutil",
        "@com_github_cockroachdb_pebble//:pebble",
        "@com_github_cockroachdb_pebble//sstable",
        "@com_github_cockroachdb_pebble//vfs",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_log//:log",
        "@org_golang_x_sync//errgroup",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "extsort_test",
    timeout = "short",
    srcs = [
        "disk_sorter_test.go",
        "external_sorter_test.go",
    ],
    embed = [":extsort"],
    flaky = True,
    deps = [
        "@com_github_cockroachdb_pebble//:pebble",
        "@com_github_cockroachdb_pebble//sstable",
        "@com_github_cockroachdb_pebble//vfs",
        "@com_github_pingcap_errors//:errors",
        "@com_github_stretchr_testify//require",
        "@org_golang_x_sync//errgroup",
        "@org_uber_go_zap//:zap",
    ],
)
